from django.db import models
from django.contrib import admin

#用户数据模型
class UserInfo(models.Model):
    #用户名，主键是防止重复写入的
    name = models.CharField(verbose_name="用户名", max_length=20, default="admin", primary_key=True)
    password = models.CharField(verbose_name="密码", max_length=20, default="666")
    macaddrs = models.CharField(verbose_name="mac地址", max_length=20,  default="01234567890ab")
    #数据库表名
    class Meta:
        db_table = 'UserInfo'
    def __str__(self):
        return self.name


#Admin必须用 list_display
class UserInfoAdmin(admin.ModelAdmin):
    list_display = ('name','password','macaddrs')

#注册
admin.site.register(UserInfo, UserInfoAdmin)



"""
class Blog(models.Model):  
    name = models.CharField(verbose_name="博客名称", max_length=100)  
    tagline = models.TextField(verbose_name="博客标语")  
    def __str__(self):              
        return self.name  
      
class Author(models.Model):  
    name = models.CharField(verbose_name="作者姓名", max_length=50)  
    email = models.EmailField(verbose_name="邮箱",)  
    def __str__(self):             
        return self.name  
       
class Entry(models.Model):  
    blog = models.ForeignKey(Blog, verbose_name="博客名称", on_delete=models.PROTECT, null=True,blank=True)  
    headline = models.CharField(verbose_name="大字标题", max_length=255)  
    body_text = models.TextField(verbose_name="博客内容",)  
    author = models.ManyToManyField(Author)  
    def __str__(self):              
        return self.headline  
"""